<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="com.javaee.ejb.entity.*,java.util.List"%>

<%@ include file="header.jsp"%>

<%@ include file="menu.jsp"%>

<%
	// Recuperation de la liste des projets et des activites
	List<Project> projectList = (List<Project>) request.getAttribute("projectList");
	List<Activity> activityList = (List<Activity>) request.getAttribute("activityList");
%>

<div class="content base home">

	<p class="titre">Mes projets</p>
	<div class="center">
		<fieldset>
			<legend>Projets auxquels je suis affect&eacute;</legend>
			<table class="fullTable">
				<thead>
					<tr>
						<th>Nom</th>
						<th>Description</th>
						<th>Budget</th>
						<th>Manager</th>
					</tr>
				</thead>
				<tbody>
		<%
			if (projectList != null && projectList.size() > 0)
			{
				for (Project project : projectList)
				{
		%>
				<tr>
					<td><a href="<%=SiteParameters.getFullServletPath("project") + "?projectId=" + project.getId()%>"><%=project.getName()%></a></td>
					<td><%=project.getDescription()%></td>
					<td><%=project.getBudget()%>&euro;</td>
					<td><%=project.getManager().getFullName()%></td>
				</tr>

		<%
				}
			
			}
			else
			{
		%>
					<tr>
						<td colspan="4">Aucun projet enregistr&eacute;</td>
					</tr>

		<%
			}
		%>
				</tbody>
			</table>
		</fieldset>
	</div>
</div>

<div class="content base home">

	<p class="titre">Mes activit&eacute;s</p>
	
	<div class="center">
		<fieldset>
			<legend>Activit&eacute;s saisies</legend>
			<table class="fullTable">
				<thead>
					<tr>
						<th>Projet</th>
						<th>R&eacute;alis&eacute;e le</th>
						<th>Temps pass&eacute;</th>
						<th>Description</th>
						<th>Statut</th>
					</tr>
				</thead>
				<tbody>
				<%
					if (activityList != null && activityList.size() > 0)
					{
						SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
						
						for (Activity activity : activityList)
						{
				%>
					<tr class="validActivity">
						<td><%=activity.getProject().getName()%></td>
						<td><%=dateFormat.format(activity.getDay())%></td>
						<td><%=activity.getTimeSpent()%>H</td>
						<td><%=activity.getDescription()%></td>
						<%
							if (activity.getIsValid()) { 
								out.print("<td class=\"validActivity\">Valide</td>");
							} else {
								out.print("<td class=\"invalidActivity\">Invalide</td>");
							}
						%>
					</tr>
				<%
						}

					}
					else
					{
				%>
					<tr>
						<td colspan="5">Aucune activit&eacute; enregistr&eacute;e</td>
					</tr>
				<%
					}
				%>
				</tbody>
			</table>
		</fieldset>
	</div>
</div>

<%@ include file="footer.jsp"%>